package com.ruoyi.module.websiteSeller.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.module.websiteSeller.domain.WebsiteSeller;
import com.ruoyi.module.websiteSeller.service.IWebsiteSellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商户微官网Controller
 * 
 * @author ${author}
 * @date 2024-01-27
 */
@RestController
@RequestMapping("/api/website/seller")
public class WebsiteSellerController extends BaseController
{
    @Autowired
    private IWebsiteSellerService websiteSellerService;

    /**
     * 查询商户微官网列表
     */
    // @PreAuthorize("@ss.hasPermi('module:seller:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebsiteSeller websiteSeller)
    {
        startPage();
        List<WebsiteSeller> list = websiteSellerService.selectWebsiteSellerList(websiteSeller);
        return getDataTable(list);
    }

    /**
     * 导出商户微官网列表
     */
    // @PreAuthorize("@ss.hasPermi('module:seller:export')")
    @Log(title = "商户微官网", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WebsiteSeller websiteSeller)
    {
        List<WebsiteSeller> list = websiteSellerService.selectWebsiteSellerList(websiteSeller);
        ExcelUtil<WebsiteSeller> util = new ExcelUtil<WebsiteSeller>(WebsiteSeller.class);
        return util.exportExcel(list, "商户微官网数据");
    }

    /**
     * 获取商户微官网详细信息
     */
    // @PreAuthorize("@ss.hasPermi('module:seller:query')")
    @GetMapping(value = "/{wSellerId}")
    public AjaxResult getInfo(@PathVariable("wSellerId") Long wSellerId)
    {
        return AjaxResult.success(websiteSellerService.selectWebsiteSellerByWSellerId(wSellerId));
    }

    /**
     * 新增商户微官网
     */
    // @PreAuthorize("@ss.hasPermi('module:seller:add')")
    @Log(title = "商户微官网", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebsiteSeller websiteSeller)
    {
        return toAjax(websiteSellerService.insertWebsiteSeller(websiteSeller));
    }

    /**
     * 修改商户微官网
     */
    // @PreAuthorize("@ss.hasPermi('module:seller:edit')")
    @Log(title = "商户微官网", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebsiteSeller websiteSeller)
    {
        return toAjax(websiteSellerService.updateWebsiteSeller(websiteSeller));
    }

    /**
     * 删除商户微官网
     */
    // @PreAuthorize("@ss.hasPermi('module:seller:remove')")
    @Log(title = "商户微官网", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wSellerIds}")
    public AjaxResult remove(@PathVariable Long[] wSellerIds)
    {
        return toAjax(websiteSellerService.deleteWebsiteSellerByWSellerIds(wSellerIds));
    }
}
